disabled managed identity on azureml compute instance #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes issue #45
Additional explanation
Ok, I did a deep dive into the problem, and I found the issue. AzureML compute instance set by default the
MSI_ENDPOINT
andMSI_SECRET
environment variables for on compute instances. Even if this managed identity has no rights. The problem is that theDefaultAzureCredential
will prioritize managed identities over CLI logins. This would be fine ifDefaultAzureCredential
would validate if it selected strategy would work. Instead, it greedily picks the first one that could work, and if it does not work, it does not try the others. So, in this case, it finds theMSI_ENDPOINT
env variable, so it decides to go for theAzureMLCredential
when this one fails to obtain to get the token, it no longer checks the other options. So in this code:We will always fall back to the
InteractiveBrowserCredential
.Sadly, the
InteractiveBrowserCredential
also does not work since azure compute instances are headless.We could replace
InteractiveBrowserCredential
withDeviceCodeCredential
. This works, but an annoying side effect is that we needed re-login every time we submit a job.So, I believe the best course of account would be to check if you are on an AzureML compute instance, and if this is the case, tell
DefaultAzureCredential
to ignore the managed identity credential. (ManagedIdentityCredential
does this by checking for the presence of theMSI_ENDPOINT
environment variable`).